<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:60:"E:\phpstudy\WWW\firstadmin/app/admin\view\content\index.html";i:1500444704;s:62:"E:\phpstudy\WWW\firstadmin/app/admin\view\common\mainHead.html";i:1500516744;s:62:"E:\phpstudy\WWW\firstadmin/app/admin\view\common\mainFoot.html";i:1500448109;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Paging</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="__ADMIN__/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="__ADMIN__/css/global.css" media="all">
    <link rel="stylesheet" href="__ADMIN__/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="__ADMIN__/css/style.css">
    <link rel="stylesheet" href="__ADMIN__/css/animate.css" />
</head>
<body>
<style>
    .layui-table .layui-form-checkbox[lay-skin=primary]{margin:0;}
</style>
<div style="margin: 15px;" class="fadeInUp animated">
    <blockquote class="layui-elem-quote">
        <form class="layui-form" style="float:left;" action="" method="post">
            <div class="layui-form-item" style="margin:0;">
                <div class="layui-input-inline">
                    <input type="text" name="key" id="key" value="<?php echo $testkey; ?>" placeholder="<?php echo lang('pleaseEnter'); ?>关键字！" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux" style="padding:0;">
                    <button type="button" id="search"  class="layui-btn"><i class="fa fa-search" aria-hidden="true"></i> 查询</button>
                    <a href="<?php echo url('index',['catid'=>input('catid')]); ?>" class="layui-btn">显示全部</a>
                </div>
            </div>
        </form>
        <a href="<?php echo url('Category/index'); ?>" class="layui-btn layui-btn-normal" style="float:right;"><i class="fa fa-undo" aria-hidden="true"></i>返回栏目</a>
        <a href="<?php echo url('add',array('catid'=>input('catid'))); ?>" class="layui-btn" style="float:right;margin-right: 15px;"><i class="fa fa-plus" aria-hidden="true"></i><?php echo lang('add'); ?></a>
        <div style="clear: both;"></div>
    </blockquote>
    <fieldset class="layui-elem-field ">
        <legend><?php echo lang('list'); ?></legend>
        <div class="layui-field-box table-responsive">
            <form class="layui-form layui-form-pane">
                <div class="layui-form">
                <table class="layui-table table-hover">
                    <thead>
                    <tr>
                        <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
                        <th><?php echo lang('order'); ?></th>
                        <th><?php echo lang('id'); ?></th>
                        <th><?php echo lang('title'); ?></th>
                        <th><?php echo lang('hit'); ?></th>
                        <th><?php echo lang('add'); ?><?php echo lang('time'); ?></th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <!--内容容器-->
                    <tbody id="con">
                    <tr>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="2">
                            <button type="button" class="layui-btn layui-btn-small layui-btn-danger" onclick="return delall();"><?php echo lang('del'); ?></button>
                            <button type="button" class="layui-btn  layui-btn-small" lay-submit="" lay-filter="sort"><?php echo lang('order'); ?></button>
                        </td>
                        <td colspan="7">
                            <!--分页容器-->
                            <div id="paged" style="text-align: right"></div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
                </div>
            </form>
        </div>
    </fieldset>
</div>

<!--模板-->
<script type="text/html" id="conTemp">
    {{# layui.each(d.list, function(index, item){ }}
    <tr>
        <td>
            <input type="checkbox" name="ids[]" value="{{ item.id }}" lay-skin="primary">
        </td>
        <td><input name='listorders[{{ item.id }}]' type='text' size='3' value='{{ item.listorder }}' class='list_order'></td>
        <td>{{ item.id }}</td>
        <td style="{{item.title_style}}">{{ item.title }}</td>
        <td>{{ item.hits}}</td>
        <td>{{ item.createtime}}</td>
        <td>
            <a href="<?php echo url('edit'); ?>?id={{item.id}}&catid={{item.catid}}" class="layui-btn layui-btn-mini">编辑</a>
            <a href="javascript:;" onclick="return del({{item.id}})" data-id="1" data-opt="del" class="layui-btn layui-btn-danger layui-btn-mini">删除</a>
        </td>
    </tr>
    {{# }); }}
</script>
<script type="text/javascript" src="__ADMIN__/plugins/layui/layui.js"></script>
<script src="__STATIC__/js/jquery.2.1.1.min.js"></script>

<script>
    layui.config({
        base: '__ADMIN__/js/'
    }).use(['paging', 'code','icheck','layer','form'], function() {
        var paging = layui.paging(),form = layui.form();layer = parent.layer === undefined ? layui.layer : parent.layer;
        paging.init({
            url: "<?php echo url('index'); ?>", //地址
            elem: '#con', //内容容器
            params: {
                'catid':"<?php echo input('catid'); ?>"
            }, //发送到服务端的参数
            tempElem: '#conTemp', //模块容器
            pageConfig: { //分页参数配置
                elem: '#paged', //分页容器
                pageSize: 15 //分页大小
            },
            success: function() { //渲染成功的回调
                //alert('渲染成功');
            },
            fail: function(msg) { //获取数据失败的回调
                //alert('获取数据失败')
            },
            complate: function() { //完成的回调
                //alert('处理完成');
                form.render();
            }
        });
        form.on('submit(sort)', function(data){
            $.post("<?php echo url('listorder',array('catid'=>input('catid'))); ?>",data.field,function(res){
                if(res.code > 0){
                    layer.msg(res.msg,{time:1000,icon:1},function(){
                        window.location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            })
        });
        var form = layui.form(),layer = layui.layer;
        //全选
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        //搜索
        $('#search').on('click', function() {
            var $this = $(this);
            var key = $('#key').val();
            if($.trim(key)=='') {
                layer.msg('<?php echo lang('pleaseEnter'); ?>关键字！');
                return;
            }
            //调用get方法获取数据
            paging.get({
                key: key //获取输入的关键字。
            });
        });
    });

    function del(id) {
        layer.confirm('你确定要删除吗？', {icon: 3}, function (index) {
            layer.close(index);
            window.location.href = "<?php echo url('listDel',['catid'=>input('catid')]); ?>?id=" + id;
        });
    }
    function delall() {
        var ids = '';
        $('input[name*=\'ids\']:checked').each(function (){
            ids += $(this).val() + ',';
        });
        layer.confirm('确认要删除选中信息吗？', {icon: 3}, function(index){
            $.post("<?php echo url('delAll'); ?>", {ids:ids,catid:"<?php echo input('catid'); ?>"}, function (result) {

                    window.location.href = result.url;

            });
            layer.close(index);
        })

    }
</script>